package zhongbo.java.air.monitor.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import zhongbo.java.air.monitor.listener.RedisSubscribeLogChannelListener;

@Configuration
@Slf4j
public class RedisListenerConfig {


    public static String I_NEED_MESSAGE = "i_need_message";
    public static String ALERT_ZONE_CHANNEL = "alert_zone_channel";
    @Autowired
    public void configListener(RedisMessageListenerContainer listenerContainer,
                               RedisSubscribeLogChannelListener logChannelListener) {
        log.info("配置redis监听器");
        listenerContainer.addMessageListener(logChannelListener, new PatternTopic(I_NEED_MESSAGE));

        listenerContainer.addMessageListener(logChannelListener, new PatternTopic(ALERT_ZONE_CHANNEL));

    }
}